{template 'common/header'}
<ul class="nav nav-tabs">
    <li {if $op=='display' } class="active" {/if}>
        <a href="{php echo $this->createWebUrl('paycenter', array('op' => 'display'));}">财务中心</a>
    </li>
	<li {if $op=='post' } class="active" {/if}>
        <a href="{php echo $this->createWebUrl('paycenter', array('op' => 'post'));}">接口申请</a>
    </li>
</ul>
{if $op == 'display'}
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title"></h3>
        <span style="color:red;">
        1、充值后不能退款，充值可以任意金额；<br>
        2、请随时留意账户可用余额，可用余额不足将导致用户订单退款；<br>
        </span>
    </div>
	<div class="panel-heading">账户金额</div>
	<div class="panel-body">
		<div class="form-group">
			<label class="col-xs-4 col-sm-3 col-md-2 control-label" style="width: 18%;font-size:22px;">可用余额：</label>
			<div class="col-sm-9 col-xs-12">
			  <span class="help-block" style="font-size:22px;color:red;margin-top: 0px;">{if empty($canuseramount)}0{else}{$canuseramount}{/if}元</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-4 col-sm-3 col-md-2 control-label" style="width: 18%;font-size:22px;">冻结金额：</label>
			<div class="col-sm-9 col-xs-12">
			  <span class="help-block" style="font-size:22px;color:red;margin-top: 0px;">{if empty($freeze_amount)}0{else}{$freeze_amount}{/if}元</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-4 col-sm-3 col-md-2 control-label" style="width: 18%;font-size:22px;">充值金额：</label>
			<div class="input-group col-md-5" style="width: 30%;">
				<input class='form-control' type="text" id='money' style="text-align: left;font-size:16px">
				<span class="input-group-btn">
					<button type="button" class="btn btn-warning" id="dopay">立即充值</button>
				</span>
			</div>
		</div>
	</div>
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content" style="max-height: 500px;max-width: 500px;">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					<h4 class="modal-title" id="myModalLabel">请使用支付宝扫描二维码充值</h4>
				</div>
				<div class="modal-body" style="text-align: center;padding: 10px;">
				    <div class="main" style="border-radius: 4px 4px 0 0;">
						<div class="test" style="height: 280px; border-radius: 4px 4px 0px 0px;">
							<div class="left" style="height: 100%; line-height: 1; padding-top: 10px; font-size: 18px;">
								<img id="moneyqrcode" src="" style="width: 200px;">
								<p>
								</p>
								<p style="color:red">
									扫码充值后，请填写支付宝<strong>订单号</strong>完成充值
								</p>
								<p>
									收款账户：stdg*****ni.hk（不要直接转账）
								</p>
								<p>
									厦门守兔网络科技有限公司
								</p>
								<p>
								    &nbsp;&nbsp;
								</p>
							</div>
							<div class="panel-body">
								<div class="form-group">
									<div class="input-group">
										<input class='form-control' placeholder="请输入支付宝订单号完成充值" type="text" id='orderno' style="text-align: left;font-size:16px">
										<span class="input-group-btn">
											<button type="button" class="btn btn-warning" id='doorderno'>立即充值</button>
										</span>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>
	<div class="panel-heading">电影票订单明细</div>
	<div class="panel-body">
		<table class="table table-hover">
			<thead>
			<tr>
				<th>订单编号</th>
				<th>订单状态</th>
				<th>市场价</th>
				<th>成本价</th>
				<th>用户座位</th>
				<th>出票座位</th>
				<th>用户手机号</th>
				<th>创建时间</th>
			</tr>
			</thead>
			<tbody>
			{loop $list1 $item}
			<tr>
				<td class="text-left">{php echo str_replace(explode("_",$item['thirdOrderId'])[0].'_',"",$item['thirdOrderId']);}</td>
				<td class="text-left">{php echo explode(":",$item['orderStatusStr'])[0]}</td>
				<td class="text-left">{php echo round($item['initPrice']/100,2);}</td>
				<td class="text-left">{if $item['realorderPrice']}{php echo round($item['realorderPrice']/100,2);}{else}{php echo round($item['initPrice']/100,2);}{/if}</td>
				<td class="text-left">{$item['seat']}</td>
				<td class="text-left">{$item['realSeat']}</td>
				<td class="text-left">{$item['reservedPhone']}</td>
				<td class="text-left">{php echo date('Y-m-d H:i',$item['createTime'])}</td>
			</tr>
			{/loop}
			</tbody>
		</table>
		{$pager1}
	</div>
    <div class="panel-heading">余额变动记录</div>
	<div class="panel-body">
		<table class="table table-hover">
			<thead>
			<tr>
			    <th>订单号</th>
				<th>变动金额</th>
				<th>变动前余额</th>
				<th>变动原因</th>
				<th>变动时间</th>
			</tr>
			</thead>
			<tbody>
			{loop $list2 $item}
			<tr>
			    <td class="text-left" style="width:20%">{$item['orderno']}</td>
				<td class="text-left">{if $item['reason'] == "电影票结算"}-{$item['money']}{else}+{$item['money']}{/if}</td>
				<td class="text-left">{$item['last_balance']}</td>
				<td class="text-left">{$item['reason']}</td>
				<td class="text-left">{php echo date('Y-m-d H:i',$item['create_time'])}</td>
			</tr>
			{/loop}
			</tbody>
		</table>
		{$pager2}
	</div>
</div>
<script>
	$(function(){
		$("#dopay").click(function(){
			if($("#money").val() < 1){
				alert("最低充值金额1元");
			}else{
				$.ajax({   
					url:"{php echo $this->createWebUrl('getmoneyqrcode')}",   
					type:'post', 
					data:{
						money:$("#money").val()
					},
					dataType:'json',
					success:function(data){
						if(data.code == 200){
							$('#myModal').modal('show');
							$('#moneyqrcode').attr('src',data.data.url);
						}else{
							alert(data.message);
						}
					}
				});
			}
		});
		$("#doorderno").click(function(){
			if(!$("#orderno").val()){
				alert("请输入支付宝订单号");
			}else{
				$.ajax({   
					url:"{php echo $this->createWebUrl('orderno')}",   
					type:'post', 
					data:{
						orderno:$("#orderno").val()
					},
					dataType:'json',
					success:function(data){
						if(data.code == 200){
							alert("充值成功");
							$('#myModal').modal('hide');
						}else{
							alert(data.msg);
						}
					}
				});
			}
		});
	});
</script>
{elseif $op == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<div class="panel panel-default">
			<div class="panel-heading" style="color:red;">
				电影票接口（申请成功后请把参数填到“参数设置—电影票设置”）
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">{if $adv['apisecret']}appKey：{else}手机号：{/if}</label>
					{if $adv['apisecret']}
					<div class="col-sm-6">
							{$adv['mobile']}
					</div>
					{else}
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='mobile' name="data[mobile]" class="form-control" value="{$adv['mobile']}" />
					</div>
					{/if}
					
				</div>
				{if $adv['apisecret']}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">appSecret：</label>
					<div class="col-sm-6">
							{$adv['apisecret']}
					</div>
				</div>
				{/if}
				{if $adv['apisecret']}
				<div class="form-group" style="display:{if $adv['apisecret']}{else}none;{/if}">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">API接口url：</label>
					<div class="col-sm-6">
							https://api.iba5.com/addons/asterye_movie/api.php?apiname=
					</div>
				</div>
				<div class="form-group" style="display:{if $adv['apisecret']}{else}none;{/if}">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">API接口url（V2版）：</label>
					<div class="col-sm-6">
							https://api.iba5.com/addons/asterye_movie/api2.php?apiname=
					</div>
				</div>
				{/if}
				{if $adv['apisecret']}
				{else}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">微信昵称：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='realname' name="data[realname]" class="form-control" value="{$adv['realname']}" />
					</div>
				</div>
				{/if}
				{if $adv['apisecret']}
				{else}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">微信号：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='wxno' name="data[wxno]" class="form-control" value="{$adv['wxno']}" />
					</div>
				</div>
				{/if}
			</div>
		</div>
		{if $adv['apisecret']}
		{else}
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
		{/if}
	</form>
</div>

{/if}

{template 'common/footer'}